package pteam;
import simulator.*;

public class AntonActor implements Actor{
	int time;
	int drive;
	int crashNumber;
	double x;
	public AntonActor(){
		time = 0;
		drive = 5;
		x =11000;
		crashNumber = 0;
	}

	public String getMaze(){
		return "GoldGen";
	}

	public void act(Robot robot){
		/*if(x <= 3){
			robot.turnLeft(90);
			time =0;
		}
		robot.goForward();
		robot.waitDistance(1);
		time = time +1;
		if(time == drive){
			robot.turnLeft(90);
			time = 0;
			drive += 5;
		}
		 */
		System.out.println("Hi");
		//System.out.println("> " +time +" " +x +" " +drive);
		// Robot never crash. Robot go until reaches wall, then alternate 
		//									between turning left and right 
		// Count each time it crashes	
		// When "crash" alternate turning left and right. right on odds, 
		//													left on evens
		// When not crash, keep going straight
		if (x<25) { 
			crashNumber = crashNumber + 1;
			if (isOdd(crashNumber)){
				robot.turnRight(100);

			}
			else robot.turnLeft(120);
		}
		robot.goForward();
		robot.waitDistance(1);

	}

	public static boolean isOdd(int number){
		if (number % 2 == 1) {
			return true;
		} 
		else return false;

	} 

	public void updateSensors(Sensor[] sensors){
		x =sensors[1].getState()[0];

	}
}
